package base.thread.create;

/**
 * @Author: my_code
 * @Create: 2020-12-06 19:04
 *
 * 1、实现Runnable接口
 * 2、重写run()方法
 * 3、创建对象实例
 * 4、创建Thread的对象
 */
public class ThreadTest2 implements Runnable{
    private String name;
    private Score score;

    public ThreadTest2(String name, Score score) {
        this.score = score;
        this.name = name;
    }

    public static void main(String[] args) {

        ThreadTest2 threadTest2 = new ThreadTest2("小华", new Score(100, 90, 88));
        new Thread(threadTest2).start();

        for (int i = 0; i < 200; i++) {
            System.out.println("main线程");
        }
    }

    @Override
    public void run() {
        for (int i = 0; i < 200; i++) {
            System.out.println("test线程-->" + name + "同学的成绩：" + score.toString());
        }
    }

    static class Score {
        private Integer Chinese;
        private Integer moth;
        private Integer english;

        public Score(Integer chinese, Integer moth, Integer english) {
            Chinese = chinese;
            this.moth = moth;
            this.english = english;
        }

        @Override
        public String toString() {
            return "Chinese=" + Chinese +
                    ", moth=" + moth +
                    ", english=" + english;
        }
    }
}
